package me.zhengjie.pm.taskprogress.domain;

import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import me.zhengjie.pm.projectbase.domain.ProjectBase;
import me.zhengjie.pm.projectstageprogress.domain.ProjectStageProgress;
import me.zhengjie.pm.taskassignment.domain.StaffWorkTask;

import javax.persistence.*;
import javax.validation.constraints.*;
import java.sql.Timestamp;
import java.io.Serializable;

/**
* @author yuxj
* @date 2020-04-14
*/
@Entity
@Data
@Table(name="task_progress")
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "id")
public class TaskProgress implements Serializable {

    /** ID */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Integer id;

    /** 任务id */
    @Column(name = "task_id",nullable = false)
    @NotNull
    private Integer taskId;

    @OneToOne
    @JoinColumn(name = "task_id",insertable = false, updatable = false)
    private StaffWorkTask staffWorkTask;

    /** 所属汇总进度表 */
    @Column(name = "collect_id")
    @NotNull
    private Integer collectId;

//    @OneToOne
//    @JoinColumn(name = "collect_id", insertable = false, updatable = false)
//    private ProjectStageProgress projectBase;

    /** 自我评定的任务完成进度 */
    @Column(name = "progress")
    private Double progress;

    /** 更新时间 */
    @Column(name = "update_time")
    private Timestamp updateTime;

    /** 完成此项工作的地点 */
    @Column(name = "address")
    private String address;

    /** 本周此项目耗时 */
    @Column(name = "time_use",nullable = false)
    @NotNull
    private Double timeUse;

    /** 风险描述 */
    @Column(name = "risk_desc")
    private String riskDesc;

    /** 工作类型 */
    @Column(name = "work_type")
    private String workType;

    /** 本周时间花费 */
    @Column(name = "workhours_detail")
    private String workhoursDetail;

    /** 后续工作 */
    @Column(name = "work_later")
    private String workLater;

    /** 本周期开始时间 */
    @Column(name = "time_begin")
    private Timestamp timeBegin;

    /** 本周期结束始时间 */
    @Column(name = "time_end")
    private Timestamp timeEnd;

    public void copy(TaskProgress source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}